package com.titaniume.java;

/**
 * @program: JavaSenior
 * @description:
 *
 *   静态代理举例
 *   特点：代理类和被代理类在编译期间，就确定下来了
 *
 *
 * @author: renfei.huang
 * @create: 2021-11-01 22:12
 */

interface ClothFactory{

    void  productCloth();
}

//代理类
class ProxyClothFactory implements  ClothFactory{


    //用被代理类对象进行实例化
    private ClothFactory clothFactory;

    public  ProxyClothFactory(ClothFactory clothFactory){
        this.clothFactory = clothFactory;
    }

    @Override
    public void productCloth() {
        System.out.println("代理工厂进行一下准备工作");
        clothFactory.productCloth();
        System.out.println("代理工厂做一下收尾工厂");
    }

}


//被代理类
class  NikeClothFactory implements ClothFactory{

    @Override
    public void productCloth() {
        System.out.println("nike工厂生产一批运动服");
    }
}



public class StaticProxyTest {

    public static void main(String[] args) {

        //创建被代理类的对象
        NikeClothFactory nikeClothFactory = new NikeClothFactory();
        //创建代理类的对象
        ProxyClothFactory proxyClothFactory = new ProxyClothFactory(nikeClothFactory);

        proxyClothFactory.productCloth();
    }

}
